package com.spring.arch;

import com.spring.arch.common.setup.ApplicationSetup;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.CommandLineRunner;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
import org.springframework.cloud.netflix.hystrix.EnableHystrix;
import org.springframework.cloud.openfeign.EnableFeignClients;

import javax.annotation.PostConstruct;
import java.util.TimeZone;

/**
 * xxl-job服务启动类
 */
@EnableFeignClients
@EnableHystrix
@EnableDiscoveryClient
@SpringBootApplication
public class JobStarterApplication implements CommandLineRunner {

    @Autowired
    private ApplicationSetup applicationSetup;

    @PostConstruct
    void init() {
        // 系统级设置
        TimeZone.setDefault(TimeZone.getTimeZone("GMT+8"));
    }

    public static void main(String[] args) {
        SpringApplication.run(JobStarterApplication.class, args);
    }

    @Override
    public void run(String... args) throws Exception {
        applicationSetup.init(args);
    }
}
